package com.it.boot.config.auth;

import lombok.extern.slf4j.Slf4j;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
@Slf4j
public class AuthInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler) {
        log.info(request.getRequestURI());

        GlobalUserContext.CurrentUser loginUser = new GlobalUserContext.CurrentUser();
        loginUser.setAccessToken(null);
        loginUser.setUserId(1L);
        GlobalUserContext.setUser(loginUser);
        return true;
    }
}
